package com.zy.fee.roadpark.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.zy.fee.roadpark.R;
import com.zy.fee.roadpark.activity.nb.NbOverpayBillDetailActivity;
import com.zy.fee.roadpark.model.M_NodeRecord;
import com.zygk.library.adapter.BaseListAdapter;
import com.zygk.library.util.Convert;
import java.util.List;

/**
 * Created by Administrator on 2018/9/13 0013.
 */

public class OverpayBillAdapter extends BaseListAdapter<M_NodeRecord> {

  public OverpayBillAdapter(Context context, List<M_NodeRecord> list) {
    super(context, list);
  }

  @Override public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.item_overpay_bill, null, false);
      holder = new ViewHolder(convertView);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    M_NodeRecord m = getData().get(position);
    holder.tvDate.setText(m.getStartTime().split(" ")[0]);
    holder.tvLotName.setText(m.getLotName());
    holder.tvMoney.setText(Convert.getMoneyString3(m.getMoney()));
    holder.tvStartTime.setText("开始时间：" + m.getStartTime().split(" ")[1]);
    holder.tvMin.setText("停车时长：" + m.getMin());

    holder.llRoot.setOnClickListener(v -> {
      Intent intent = new Intent(mContext, NbOverpayBillDetailActivity.class);
      intent.putExtra(NbOverpayBillDetailActivity.INTENT_NODE_RECORD_ID, m.getNodeRecordID());
      mContext.startActivity(intent);
    });

    return convertView;
  }

  static class ViewHolder {
    @BindView(R.id.tv_date) TextView tvDate;
    @BindView(R.id.tv_lotName) TextView tvLotName;
    @BindView(R.id.tv_money) TextView tvMoney;
    @BindView(R.id.tv_startTime) TextView tvStartTime;
    @BindView(R.id.tv_min) TextView tvMin;
    @BindView(R.id.ll_root) LinearLayout llRoot;

    ViewHolder(View view) {
      ButterKnife.bind(this, view);
    }
  }
}
